package com.lyz.apidemo;

import java.util.Arrays;

/**
 * @ClassName ArraysTest10
 * @Description 自定义排序
 * @Author 2214361854
 * @Date 2022/2/21 10:47
 * @Version 1.0
 */
public class ArraysTest10 {
    public static void main(String[] args) {
        Stuent[] stuents = new Stuent[3];
        stuents[0] = new Stuent("小王",23,185.5);
        stuents[1] = new Stuent("小星",13,175.5);
        stuents[2] = new Stuent("小明",20,170.5);
        System.out.println(Arrays.toString(stuents));
//        Double.compare(); double数据比较
        //年龄排序
        Arrays.sort(stuents, (o1, o2) -> o1.getAge()-o2.getAge());
        System.out.println(Arrays.toString(stuents));
        //升高排序
        Arrays.sort(stuents, (o1, o2) -> Double.compare(o1.getHeight(),o2.getHeight()));
        System.out.println(Arrays.toString(stuents));
    }
}
